def edit_distance(a, b):
    m, n = len(a), len(b)
    # 创建(m+1) x (n+1)的二维数组
    dp = [[0] * (n + 1) for _ in range(m + 1)]
    # 初始化边界条件
    # dp[i][0] = i 表示将字符串a的前i个字符转换为空字符串需要i次删除操作
    # dp[0][j] = j 表示将空字符串转换为字符串b的前j个字符需要j次插入操作
    for i in range(1, m + 1):
        dp[i][0] = i
    for j in range(1, n + 1):
        dp[0][j] = j
    # 动态规划计算编辑距离
    for i in range(1, m + 1):
        for j in range(1, n + 1):
            if a[i - 1] == b[j - 1]:
                dp[i][j] = dp[i - 1][j - 1]
            else:
                dp[i][j] = min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]) + 1
    return dp[m][n]

a = input()
b = input()
print(edit_distance(a, b))
